@extends('admin.master')

@section('top')
	<span class="top-title pull-left">我的录入</span>
@endsection

@section('content')
<div class="section-search mb10">
	<form class="form-inline" method="get">
	@if ($request->has('progress'))
	<input type="hidden" name="progress" value="{{ $request->input('progress') }}">
	@endif
	<div class="form-group">
		{!! Form::text('word', null, ['class'=>'form-control len wd-search', 'id'=>'kw', 'placeholder'=>'客户名称或域名']) !!}
	</div>
	<div class="form-group">
		<label class="control-label">备案：</label>
		{!! Form::select('icp_status', ['全部'] + config('system.icp_status'), isset($where['icp_status']) ? $where['icp_status'] : 0, ['class'=>'form-control']) !!}
	</div>
	<button type="submit" class="btn btn-default">查询</button>
	</form>
</div>
<div class="section-tab mb10">
	<ul class="nav nav-tabs">
		<li @if (!$request->has('progress') && !$request->has('status')) class="active" @endif>
			<a href="{{ route('admin.myinput') }}">
				所有录入
				<i class="p-count">({{ $counts->sum() }})</i>
			</a>
		</li>
		<li @if ($request->input('progress') == 4) class="active" @endif>
			<a href="{{ route('admin.myinput', ['progress'=>4]) }}">
				录入中
				<i class="p-count">({{ $counts->get(4, 0) }})</i>
			</a>
		</li>
		<li @if ($request->input('progress') == 5) class="active" @endif>
			<a href="{{ route('admin.myinput', ['progress'=>5]) }}">
				待发布
				<i class="p-count">({{ $counts->get(5, 0) }})</i>
			</a>
		</li>
		<li @if ($request->input('status') == 3) class="active" @endif>
			<a href="{{ route('admin.myinput', ['status'=>3]) }}">
				已上线
				<i class="p-count">({{ $counts->get(6, 0) + $counts->get(7, 0) }})</i>
			</a>
		</li>
	</ul>
</div>
<div class="gridSection">
{!! Form::open(['url'=>'admin/order']) !!}
	<table class="table table-hover table-list order-tb">
		<thead>
			<tr>
				<th width="60" class="text-center">ID</th>
				<th>提单时间</th>
				<th>上线时间</th>
				<th>客户名称</th>
				<th class="text-center">套餐</th>
				<th>订单类型</th>
				<th class="text-center">年限</th>
				<th>域名</th>
				<th class="text-center">设计师</th>
				<th>业务员</th>
				<th class="text-center">备案</th>
				<th>签单金额</th>
				<th>尾款</th>
				<th>进度</th>
				<th class="text-right">操作</th>
			</tr>
		</thead>
		<tbody>
			@if (!$data->isEmpty())
				@foreach ($data as $value)
					<tr>
						<td class="text-center">{{ $value->id }}</td>
						<td>{{ $value->created_at->format('Y-m-d') }}</td>
						<td>{{ $value->finished_at > '0000-00-00 00:00:00' ? $value->finished_at->format('Y-m-d') : null }}</td>
						<td>
						{{ $value->customer->name }}
						@if ($value->expedited)
							<span class="label label-warning">加急</span>
						@endif
						</td>
						<td class="text-center">
							<a class="text-success lan-package" href="{{ url('admin/lan-complete?order_id='.$value->id) }}">{{ config('system.web_package')[$value->web_package] }}</a>
						</td>
						<td>
							<span class="label label-info">{{ $system['product'][$value->type][$value->product] }}</span>
						</td>
						<td class="text-center">{{ $value->year }}</td>
						<td><a href="http://{{ $value->domain }}" target="_blank">{{ $value->domain }}</a></td>
						<td class="text-center">
							<div class="user-items">{!! $value->present()->worker !!}</div>
						</td>
						<td>{{ $value->saler->name or '' }}</td>
						<td class="text-center">
							<?php
								$statusClass = [1=>'default', 2=>'info', 3=>'success', 4=>'danger'];
							?>
							<span class="label label-{{ $statusClass[$value->icp_status] }}">{{ $system['icp_status'][$value->icp_status] }}</span> 
						</td>
						<td><span class="text-success">{{ (int)$value->amount }}</span></td>
						<td>
							@if ($value->tail_amount > 0)
								<span class="text-danger">{{ (int)$value->tail_amount }}</span>
							@else
								<span class="text-muted">/</span>
							@endif
						</td>
						<td><span class="text-success">{{ $system['progress'][$value->progress] }}</span></td>
						<td class="text-right">
							<div class="toolbar">
								<a href="{{ route('admin.order.show', $value->id) }}" class="btn-link">详情</a>
								<span class="text-explode ">|</span>
								<a href="{{ route('admin.order.edit', $value->id) }}" class="btn-link">修改</a>
							</div>
						</td>
					</tr>
				@endforeach
			@endif
		</tbody>
	</table>
	@if (!$data->isEmpty())
	<table class="table table-footer">
		<tfoot>
			<tr>
				<td>
					<div class="pagination-box">
						<div class="pull-right">
							<div class="pagination-info">共有{{ $data->total() }}条， 每页显示：20条</div>
							{!! $data->appends(request()->except('page'))->render() !!}
						</div>
					</div>				
				</td>
			</tr>
		</tfoot>
	</table>
	@else
	<div class="simple-none-data text-center">
		<i class="fa fa-exclamation-circle text-size-20 text-muted" style="vertical-align: middle"></i> 
		<span class="text-size-14 inline-block ml5">没有查询到符合条件的记录</span>
	</div>
	@endif
{!! Form::close() !!}
</div>
@endsection

@section('foot')
<!-- Modal -->
<div class="modal fade" id="dialog-user" tabindex="-1" role="dialog">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="true"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title">用户信息</h4>
        </div>
        <div class="modal-body clearfix">

        </div>
        <div class="modal-footer">
          <button class="btn btn-primary" data-dismiss="modal">确定</button>
        </div>
    </div>
  </div>
</div>
<!-- Modal End -->
<script type="text/javascript">
	$('.order-user').on('click', function() {
		$('#dialog-user').find('.modal-body').html($(this).next('.user-info').html());
		$('#dialog-user').modal('show');
	});
</script>	
@endsection